package logic

import (
	"context"
	"user_srv/mobile/mysql"

	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddRealNameLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAddRealNameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddRealNameLogic {
	return &AddRealNameLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *AddRealNameLogic) AddRealName(in *user.AddRealNameRequest) (*user.AddRealNameResponse, error) {
	// todo: 新增实名信息

	u := mysql.UserRealName{
		UserId:   int(in.UserId),
		RealName: in.RealName,
		IdCared:  in.IdCared,
	}
	err := u.CreateUser()
	if err != nil {
		logx.Error("新增信息失败", err)
		return nil, err
	}

	return &user.AddRealNameResponse{}, nil
}
